#include "../ctlText.h"
#include "../x/textpack.h"
#include <Windows.h>

namespace swui
{
	ctlText ctlText::toString() const
	{
		if(!isWideChar())
			return *this;
		unsigned len = WideCharToMultiByte(CP_OEMCP, 0, getWideString(), -1, 0, 0, 0, 0);
		ctlText text("");
		text._isWide = false;
		text._string.resize(len + 1, 0);
		WideCharToMultiByte(CP_OEMCP, 0, getWideString(), -1, &text._string[0], len + 1, 0, 0);
		return std::move(text);
	}
	ctlText ctlText::toWideString() const
	{
		if(isWideChar())
			return *this;
		_ctlInterior::textpack pack;
		pack.set(getString());
		ctlText text(L"");
		text._isWide = true;
		text._wideString = std::move(pack.stdwstr());
		return std::move(text);
	}
}